import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 引入字体图标
import './assets/fonts/iconfont.css'
// 全局样式表
import './assets/css/global.css'

Vue.config.productionTip = false

// 富文本
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

Vue.use(VueQuillEditor)
// 表格树形
import TreeTable from 'vue-table-with-tree-grid'

Vue.component('tree-table', TreeTable)
// axios
import axios from 'axios'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

// 进度条插件
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 请求拦截器添加token  也就是预处理
axios.interceptors.request.use(config => {
  // 展示进度条
  NProgress.start()
  // console.log(config)
  // 为请求头对象添加Authorization字段
  config.headers.Authorization = sessionStorage.getItem('token')
  return config
})

// 响应拦截器
axios.interceptors.response.use(
  config => {
    // 关闭进度条
    NProgress.done()
    return config
  },
  err => err
)
import moment from 'moment'
// 时间过滤器
Vue.filter('fromData', val => {
  return moment(val).format('YYYY-MM-DD HH:MM:ss') // 格式化
})
Vue.prototype.$axios = axios
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
